local Class_EntityFactory = class()
EntityFactory = Class_EntityFactory.new()

function Class_EntityFactory:Init()
    self.EntityAsset = {}
    local entityConfig = ConfigTable[ConfigName.Entity]
    for key, value in pairs(entityConfig) do
        local entity = {}
        entity.ID = tonumber(value["ID"])
        entity.Name = tostring(value["Name"])
        entity.ResourceName = tostring(value["ResourceName"])
        entity.Asset = ResourceManager.Instance:LoadPrefab("SceneResources", entity.ResourceName)
        self.EntityAsset[entity.ID] = entity
    end
end

function Class_EntityFactory:CreateEntity(Param)
    local Template = self.EntityAsset[Param.ModelID]
    if Template == nil then
        print("实例化模型出错", Param.ModelID)
        return 
    end

    local itemGo = ObjectPool:PullFromPool(Param.ModelID)
    if LuaUtils:IsNil(itemGo) then
        itemGo = GameObject.Instantiate(Template.Asset, Param.Position, Param.Rotation)
    end

    itemGo.name = Param.Name
    if Param.Parent then
        itemGo.transform:SetParent(Param.Parent.transform, false)
    end

    return itemGo
end
